
/**
 * 提交时检查用户名和密码是否为空,验证码是否正确
 * @returns {boolean} 都为true才允许提交
 */
    function check(){
    var n=document.getElementById("name").value;
    var p=document.getElementById("psw").value;
    //var yz=document.getElementById("yz").value;
    //var tu=document.getElementById("tu");
    if(n==""){
        alert("请输入用户名");
        return false;
    }
    if(p==""){
        alert("请输入密码");
        return false;
    }
    var yan = document.getElementById('yan');
    //转换成小写字母比较
    if(yan.value.toLowerCase() == str.toLowerCase()){
        return true;
    }
    if(yan.value.toLowerCase() != str.toLowerCase()){
        alert("验证码错误");
        return false;
    }

}
var str;
function createNewCode() {
    var arr = ['0','1','3','4','5','6','7','8','9','a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z','A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'];
    str = "";
    var strlength = 4;
    for(var i = 0; i < strlength; i++)
    {
        var num = Math.floor(Math.random()*arr.length);
        str+= arr[num];
    }
    var btn = document.getElementById("code");
    btn.value = str;
}
//加载时创建验证码
window.onload = createNewCode;


//点击微信按钮弹出二维码
function rec(){
    var code=document.getElementById("login");
    code.innerHTML="<div style='text-align: center;'> <h2 style='text-align: center;margin-top: 10px;'>扫一扫</h2>" +
    "<img src='./imgs/wec.jpg' style='width=300px; height=300px;'   />" +
        "<p><a href='./login.php'style='text-decoration: none; color:  rgb(9, 170, 255); margin: 0 auto;' >账号密码登陆</p>"+
    "</div>" ;
}
